package com.su.test;

public abstract class Strategy {
    protected int steps;      //移动步数
    protected   Node lastNode;  //获取目标节点，可以根据目标节点找到其父节点，依次类推，找到初始节点

    protected int length;                 //数码长度，可以处理非八数码，例如十五数码
    protected int col;        //数码列数


    protected int initArr[];              //初始状态的八数码
    protected int targetArr[];            //目标状态的八数码


    public abstract void run();

    /**
     * @Description         获取空格移位后的数码
     * @param curArr        当前数码
     * @param emptyIndex    当前数码空格位置
     * @param pos           空格偏移量
     * @return              返回移位后的数码
     **/
    protected int[] move(int curArr[],int emptyIndex,int pos){
        int []nextArr = new int[length];
        System.arraycopy(curArr,0,nextArr,0,length);
        int temp;
        temp = nextArr[emptyIndex];
        nextArr[emptyIndex] = nextArr[emptyIndex + pos];
        nextArr[emptyIndex + pos] = temp;

        return nextArr;
    }


    public int getSteps() {
        return steps;
    }

    public void setSteps(int steps) {
        this.steps = steps;
    }

    public Node getLastNode() {
        return lastNode;
    }

    public void setLastNode(Node lastNode) {
        this.lastNode = lastNode;
    }

    public int getCol() {
        return col;
    }

    public void setCol(int col) {
        this.col = col;
    }

    public int getLength() {
        return length;
    }

    public void setLength(int length) {
        this.length = length;
    }

    public int[] getInitArr() {
        return initArr;
    }

    public void setInitArr(int[] initArr) {
        this.initArr = initArr;
    }

    public int[] getTargetArr() {
        return targetArr;
    }

    public void setTargetArr(int[] targetArr) {
        this.targetArr = targetArr;
    }


}
